<template>
<view>
<view class="receive" style="background-image:url(./../img/youxiao_bj.pn);background-size: cover;">
  <view class="r-before">
    <view class="r-top">
      <view class="receive-warp">
        <text class="amount">5</text>
        <text>元优惠劵</text>
      </view>
      <navigator class="purchase-btn fr">
        <view>
          <text>立即使用</text>
        </view>
      </navigator>
      <view class="purpose">
        <text>全网通用（团购和特价商品除外）</text>
      </view>
    </view>
    <view class="r-bottom">
      <text>有效期至2018年5月30日</text>
    </view>
  </view>
</view>
<view class="receive" style="background-image:url(./../img/youxiao_bj.pn);background-size: cover;">
  <view class="r-before">
    <view class="r-top">
      <view class="receive-warp">
        <text class="amount">20</text>
        <text>元优惠劵</text>
      </view>
      <navigator class="purchase-btn fr cancel">
        <view>
          <text>取消使用</text>
        </view>
      </navigator>
      <view class="purpose">
        <text>全网通用（团购和特价商品除外）</text>
      </view>
    </view>
    <view class="r-bottom">
      <text>有效期至2018年5月30日</text>
    </view>
  </view>
</view>
</view>
</template>

<script>
// var util = require('../../utils/util.js');
// import request from '../../utils/requestUtils.js';
// import {
//   xcxId,
//   enablecoupon_url
// } from "../../utils/data.js";
var app = getApp();

export default {
  data() {
    return {
      enablecoupon: ""
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.enablecouponFun();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  methods: {
    enablecouponFun: function (amount, goodsIds) {
      var openId = wx.getStorageSync("openid");
      var $this = this;
      var params = {
        amount: 1,
        goodsIds: 0
      };
      request.POST({
        url: enablecoupon_url,
        params: params,
        header: request.postHeader,
        success: function (res) {
          var resultData = res.data.data;
          console.log(resultData);
          $this.setData({
            enablecoupon: resultData
          });
        },
        fail: function (res) {//失败后的逻辑
        }
      });
    }
  }
};
</script>
<style>
@import "./usecoupon.css";
</style>